package com.md.model;

import java.io.UnsupportedEncodingException;
import java.net.URLEncoder;
import java.util.Random;

import com.md.util.DataUtils;

public class BaseModel {

	private String clientId = null;

	public String encodeURI(String url) throws UnsupportedEncodingException {
		if (DataUtils.isBlank(url)) {
			return "";
		} else {
			return URLEncoder.encode(url, "utf-8");
		}
	}

	public String getRandomHex() {
		return Integer.toHexString(new Random().nextInt(Integer.MAX_VALUE));
	}

	public String getClientId() {
		if (this.clientId == null) {
			this.clientId = this.getRandomHex();
		}
		return this.clientId;
	}

}
